package com.sc.controller;

import com.sc.common.pojo.CommonResult;
import com.sc.common.pojo.EasyUiDataGridResult;
import com.sc.pojo.TbItem;
import com.sc.service.ItemService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/item")
public class ItemController {

    @Autowired
    private ItemService itemService;

    @RequestMapping("/{itemId}")
    @ResponseBody
    private   TbItem getitem(@PathVariable("itemId") Long id){
        TbItem item = itemService.getitemById(id);
        return item;
    }

    @RequestMapping("/list")
    @ResponseBody
    public EasyUiDataGridResult getList(Integer page,Integer rows){
        EasyUiDataGridResult result = itemService.getItemList(page,rows);
        return result;
    }

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult saveItem(TbItem item, String desc,String itemParams){
        return itemService.createItem(item,desc,itemParams);
    }


}
